package flc.ast;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.huawei.hms.videoeditor.HmsVeModule;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.AlbumFragment;
import flc.ast.fragment.EditFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.view.container.StkRelativeLayout;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    public static StkRelativeLayout rlDelete;
    public static TextView tvDelete;

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
        HmsVeModule.init(this);
        rlDelete = mDataBinding.rlAlbumEditDelete;
        tvDelete = mDataBinding.tvAlbumEditDelete;
    }

    @Override
    protected void onClickCallback(View v) {
        super.onClickCallback(v);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.llHome));
        listFragment.add(new FragmentViewBinder(EditFragment.class, R.id.llEdit));
        listFragment.add(new FragmentViewBinder(AlbumFragment.class, R.id.llAlbum));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.tab_1);
                mDataBinding.ivHomeSel.setVisibility(View.VISIBLE);
                break;
            case R.id.llEdit:
                mDataBinding.ivEdit.setImageResource(R.drawable.tab_2);
                mDataBinding.ivEditSel.setVisibility(View.VISIBLE);
                break;
            case R.id.llAlbum:
                mDataBinding.ivAlbum.setImageResource(R.drawable.tab_3);
                mDataBinding.ivAlbumSel.setVisibility(View.VISIBLE);
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.tab_4);
                mDataBinding.ivMySel.setVisibility(View.VISIBLE);
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.tab_1a);
        mDataBinding.ivHomeSel.setVisibility(View.INVISIBLE);
        mDataBinding.ivEdit.setImageResource(R.drawable.tab_2a);
        mDataBinding.ivEditSel.setVisibility(View.INVISIBLE);
        mDataBinding.ivAlbum.setImageResource(R.drawable.tab_3a);
        mDataBinding.ivAlbumSel.setVisibility(View.INVISIBLE);
        mDataBinding.ivMy.setImageResource(R.drawable.tab_4a);
        mDataBinding.ivMySel.setVisibility(View.INVISIBLE);
    }

}